package com.qf.homeproject;

import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.ListView;

import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.qf.config.AppConfig;

public class SearchActivity extends Activity
{

	@ViewInject(R.id.searchactivity_listview)
	private ListView lv;

	@ViewInject(R.id.title_baredti_Id)
	private EditText keyWord;

	private String cityId;;

	private String searchListUrl;

	private String cityName;

	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_search);
		initView();
		initData();
		initQuery();
	}

	private void initQuery()
	{
		keyWord.addTextChangedListener(new TextWatcher()
		{

			@Override
			public void onTextChanged(CharSequence s, int start, int before,
					int count)
			{
				// TODO Auto-generated method stub

			}

			@Override
			public void beforeTextChanged(CharSequence s, int start, int count,
					int after)
			{
				// TODO Auto-generated method stub

			}

			// 关键词输入之后的监听事件
			@Override
			public void afterTextChanged(Editable s)
			{
				searchListUrl = String.format(AppConfig.SEARCH_HOUSE_INPUT,
						s.toString(), cityName);
				Log.i("info", "列表的URL地址为:" + searchListUrl);
				// DownLoadNetHomeData.downLoad(searchListUrl);
			}
		});
	}

	private void initData()
	{
		// 利用Httputils下载网络数据并进行解析然后返回

	}

	private void initView()
	{
		ViewUtils.inject(this);
		cityId = getIntent().getStringExtra("cityId");
		cityName = getIntent().getStringExtra("cityName");
	}

	/**
	 * 返回到主页面
	 * 
	 * @param view
	 */
	public void back(View view)
	{
		finish();
	}

	class searchAdapter extends BaseAdapter
	{

		@Override
		public int getCount()
		{
			// TODO Auto-generated method stub
			return 0;
		}

		@Override
		public Object getItem(int position)
		{
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public long getItemId(int position)
		{
			// TODO Auto-generated method stub
			return 0;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent)
		{
			// TODO Auto-generated method stub
			return null;
		}

	}

}
